package com.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.stereotype.Service;

import com.core.visaInfo.dao.VisaInfoDao;
import com.core.visitor.dao.VisitorDao;
import com.core.visitor.dto.VisitorSearchCondition;
import com.core.visitor.pojo.Visitor;
@Service
public class ExceInputUtil {
	@Resource
	private VisitorDao visitorDao;
	@Resource
	private VisaInfoDao visaInfoDao;
	public String  inputExcelReturn(String road) {
//		获取该签证的游客
		String fielName =road.substring(road.lastIndexOf(File.separator)+1);
		Long visaIdLong =Long.parseLong(fielName.substring(0,fielName.indexOf(".")));
		System.out.println(visaIdLong);
		VisitorSearchCondition sc =new VisitorSearchCondition();
		sc.setVisaInfoId(visaIdLong);
		List<Visitor> visitorList = visitorDao.getVisitorList2(sc);
//		读取excel表格并初始化对象
		try {
			InputStream is  = new FileInputStream(road);
			HSSFWorkbook hssfWorkbook = new HSSFWorkbook(is);//整个Ecel
			HSSFSheet hssfSheet =hssfWorkbook.getSheetAt(0);//第一页
//			处理当前页
			for(int rowNum=1;rowNum<hssfSheet.getLastRowNum();rowNum++){
//				初始化行
				HSSFRow hssfRow = hssfSheet.getRow(rowNum);
				int minColIx = hssfRow.getFirstCellNum();
				int maxColIx = hssfRow.getLastCellNum();
				List<String>rowList =new ArrayList<String>();
				for(int colNum=minColIx;colNum<maxColIx;colNum++){
					HSSFCell cell = hssfRow.getCell(colNum);
				}
			} 
			
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String nameString =visitorList.get(0).getName();
		System.out.println(nameString);
		return null;
				
	}

}
